<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>

		<script type="text/javascript">
			// 根据课件动物类的例子，尝试动物飞的方法，然后子类进行重写，实现多态。
			function Animal(type) {
				this.type = type;
			}
			Animal.prototype.fly = function() {
				console.log(this.type + "在飞");
			};

			function F() {}
			F.prototype = Animal.prototype;

			function Sparrow() {
				Animal.call(this, '麻雀');
			}
			Sparrow.prototype = new F();
			Sparrow.prototype.constructor = Sparrow;
			Sparrow.prototype.fly = function() {
				console.log(this.type + "在天上飞");
			}
			let sparrow = new Sparrow()
			sparrow.fly();
		</script>
	</body>
</html>
